import { useModel, history } from "umi";
import { App } from "antd";

import AddProxyServerForm from "../components/ProxyServers/Add";
import EditProxyServerForm from "../components/ProxyServers/Edit";

const useHelperProxyServers = () => {
    const { modal } = App.useApp();
    const { setModalVisible, setModalTitle, setModalWidth, setModalComponent } = useModel("global.modal");

    const openCreateModal = ({ reloadData }) => {
        setModalTitle("添加新的代理服务信息");
        setModalVisible(true);
        setModalWidth(750);
        setModalComponent(<AddProxyServerForm reloadData={reloadData} />);
    };

    const openEditModal = ({ record, reloadData }) => {
        setModalTitle("编辑代理服务信息");
        setModalVisible(true);
        setModalWidth(750);
        setModalComponent(<EditProxyServerForm record={record} reloadData={reloadData} />);
    };

    return {
        openCreateModal,
        openEditModal,
    };
};

export default useHelperProxyServers;
